package com.mming.sso.filter;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mming.sso.bean.ResponseWrapper;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class BaseFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    }

    void outputResponse(int status, HttpServletResponse response) throws IOException {
        ResponseWrapper res = new ResponseWrapper(status);
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(res);
        response.setContentType("application/json; charset=UTF-8");
        response.setStatus(status);
        response.getWriter().print(json);
        response.getWriter().close();
    }
}
